import storage from "@/utils/storage";

const state = {
  userInfo: storage.get("userInfo"),
  orderData: {},
  base64Url: "",
  imagePreview: [],
};
const mutations = {
  setUserInfo(state, data) {
    storage.set("token", data.token || "");
    storage.set("userInfo", data);
    state.userInfo = data;
  },
  setOutLogin(state) {
    storage.remove("token");
    storage.remove("userInfo");
    state.userInfo = "";
  },
  setOrderData(state, data) {
    state.orderData = data;
  },
  setPlateImg(state, data) {
    state.base64Url = data;
  },

  setImagePreview(state, data) {
    state.imagePreview = data;
  },
};
const getters = {
  orderDataGetter: (state) => state.orderData,
  userInfoGetter: (state) => state.userInfo,
  base64UrlGetter: (state) => state.base64Url,
  imagePreviewGetter: (state) => state.imagePreview,
};
const actions = {};

export default {
  name: "user",
  state,
  mutations,
  getters,
  actions,
};
